#include "Metgine/Core/Camera.hpp"
#include "Metgine/Core/Object.hpp"
#include "Metgine/Core/Game.hpp"

namespace Metgine
{
namespace Core
{

Camera::Camera()
{

    m_action = CameraAction::None;
    m_targetObject = NULL;

}

void Camera::SetPosition(const Vector2f& point)
{

    m_position = point;
    m_view.SetCenter(point.x, -point.y);

}

void Camera::SetViewSize(int width, int height)
{

    m_view.SetFromRect(sf::FloatRect(0, 0, (float)width, (float)height));

}

const sf::View& Camera::GetView() const
{

    return m_view;

}

Vector2f Camera::GetPosition() const
{

    return m_position;

}

Vector2f Camera::GetWorldPosition() const
{

    const sf::FloatRect& rect = m_view.GetRect();

    return GetWorldPosition((int)(rect.GetWidth() * 0.5f), (int)(rect.GetHeight() * 0.5f));

}

Vector2f Camera::GetWorldPosition(int screenX, int screenY) const
{

    const sf::FloatRect& rect = m_view.GetRect();

    return Vector2f(rect.Left + screenX, -rect.Bottom + (rect.GetHeight() - screenY));

}

void Camera::Move(int deltaX, int deltaY, bool internalMove)
{
}

void Camera::MoveTo(Object* object, bool track, bool instant)
{
}

bool Camera::Update(float elapsedTime)
{
    return false;
}

void Camera::StartTracking(Object* object)
{
}

void Camera::StopTracking()
{

    m_targetObject = NULL;
    m_action = CameraAction::None;

}

}; // Graphics

}; // Metgine
